<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class SmsCodeSendRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'mobile_area' => 'required',
            'mobile' => 'required',
            'card_no' => 'required',
            'lang' => 'sometimes'
        ];
    }

    public function messages(): array
    {
        $mobileAreaMsg = 'Mobile phone international code required';
        $mobileMsg = 'Mobile phone number required';
        $cardMsg = 'The card number is required';

        if ($this->input('lang') == 'fr') {

            $mobileAreaMsg = 'Le code international du téléphone portable est requis';
            $mobileMsg = 'Numéro de téléphone portable requis';
            $cardMsg = 'Le numéro de carte est requis';
        }elseif ($this->input('lang') == 'de') {

            $mobileAreaMsg = 'Der internationale Handycode ist erforderlich';
            $mobileMsg = 'Handynummer erforderlich';
            $cardMsg = 'Die Kartennummer ist erforderlich';
        }elseif ($this->input('lang') == 'nl') {

            $mobileAreaMsg = 'Internationaal mobiel telefoonnummer vereist';
            $mobileMsg = 'Mobiel telefoonnummer vereist';
            $cardMsg = 'Het kaartnummer is vereist';
        }elseif ($this->input('lang') == 'it') {

            $mobileAreaMsg = 'È richiesto il codice internazionale del cellulare';
            $mobileMsg = 'Numero di cellulare richiesto';
            $cardMsg = 'Il numero della carta è richiesto';
        }elseif ($this->input('lang') == 'es') {

            $mobileAreaMsg = 'Se requiere el código internacional del teléfono móvil';
            $mobileMsg = 'Se requiere el número de teléfono móvil';
            $cardMsg = 'Se requiere el número de tarjeta';
        }

        return [
            'mobile_area.required' => $mobileAreaMsg,
            'mobile.required' => $mobileMsg,
            'card_no.required' => $cardMsg
        ];
    }
}
